﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SHop.admin
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        private DulieuDataContext dc = new DulieuDataContext();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.DropDownList1.DataSource = this.dc.Themes.ToList();
                this.DropDownList1.DataTextField = "name";
                this.DropDownList1.DataValueField = "id";
                this.DropDownList1.DataBind();

                this.Label1.Text = string.Empty;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                Theme th = this.dc.Themes.Single(t => t.status == 1);
                th.status = 0;
                this.dc.SubmitChanges();

                Theme th1 = this.dc.Themes.Single(t1 => t1.id == Convert.ToInt32(this.DropDownList1.SelectedValue));
                th1.status = 1;
                this.dc.SubmitChanges();

                this.Label1.Text = "Change theme ok . . .";
            }
            catch
            {
                this.Label1.Text = "False !";
            }
       }
    }
}